<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // Proxy
    var obj = {
      a: 10,
      b: 20
    }
    var objProxy = new Proxy(obj, {
      get (target, key) {
        console.log('getter触发了');
        // getter 拦截 取值的操作
        return target[key]
      },
      set (target, key, value) {
        console.log('setter触发了');
        // 拦截赋值操作
        target[key] = value
      }
    })
    console.log(objProxy.a);
    objProxy.a = 1000
    console.log(objProxy.a);
  </script>
</body>
</html>